<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>

<%
	request.setAttribute("modelConfigPath", "stock");
%>
<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>

<style >
	.template{display:none}
	.hidden{display:none}
	.bootstrap-duallistbox-container select.form-control{
		height:160px !important;
	}
</style>
 	<input type="hidden" value='${stocksJson}' id="stocksJson" /> 
 <t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
 	<div style="margin-top:10px; height:485px;overflow-y:auto; overflow-x:hidden;" >
	<!-- <div class="detailed-navbar-content panel-body"> -->
		<t:form id="form2" modelAttribute="stockSearch"  method="POST" action="/stock/inventory/queryCargos" cssClass="form-horizontal">
			<!-- <div class="panel-body"> -->
			<t:formgroup>
				<t:label path="cargoName" cssClass="col-sm-1" />
				<t:input path="cargoName" colClass="col-sm-3" />
				<t:label path="cargoNo" cssClass="col-sm-1" />
				<t:input path="cargoNo" colClass="col-sm-3" />
			</t:formgroup>
		</t:form>
		
		<t:form id="inventory" modelAttribute="inventory"  method="POST" action="/stock/inventory/save" cssClass="form-horizontal">
			<t:hidden path="inventoryId"/>
			<t:hidden path="deleteMark"/>
			<t:hidden path="createUserId"/>
			<t:hidden path="inventoryState"/>
			<t:hidden path="shopId"/>
			<t:formgroup>
				<t:label path="inventoryNo" cssClass="col-sm-1 col-xs-1" />
				<t:input path="inventoryNo" readonly="true" colClass="col-sm-3 col-xs-3" ></t:input>
				<t:label path="createDate" cssClass="col-sm-1 col-xs-1" />
				<t:datetime2  inputGroupIcon="icon-calendar" path="createDate" colClass="col-sm-3 col-xs-3" ></t:datetime2>
				<t:label path="createUserName" cssClass="col-sm-1 col-xs-1 " />
				<t:input path="createUserName" colClass="col-sm-3 col-xs-3" ></t:input>
			</t:formgroup>	
			<t:formgroup>
				<t:label path="comment" cssClass="col-sm-1 col-xs-1 " />
				<t:textarea path="comment" rows="1" colClass="col-sm-11 col-xs-11" />
			</t:formgroup>
			<t:formgroup>
				<t:label path="adjustmentCargoId" cssClass="col-sm-1 col-xs-1 "></t:label>
	 			<t:listbox path="adjustmentCargoId" colClass="col-sm-11 col-xs-11"></t:listbox>
	 		</t:formgroup>
		</t:form>
	</div>
	<t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
		<c:if test="${t_mode ne 3}">
			<t:button icon="icon-floppy-disk" onclick="submitForm()" laddaType="progress" cssClass="btn-info" csize="sm" >创建盘点单</t:button>
		</c:if>
	</t:panelFoot>
</t:panel>

<script type="text/javascript">
$(function() {
	
	
	
	$("#cargoName,#cargoNo").bind('input propertychange', function() {
		searchCargos();
	});
	
});

function listboxExBefore(){
	searchCargos();
}

function searchCargos(){
	 var stuffData=[];
	var url =$.getVirtualPath()+"/stock/inventory/queryCargos";
	
    $.ajax({
        type: 'get',
        dataType: "json",
        url: url,
        data: $("form#form2").serialize(),
        async: false,
        success: function (result) {
        	stuffData.splice(0,stuffData.length);
		    $("#adjustmentCargoId").empty();
		    if(result!=null){
	   			var stocksJson =result.data;
	   			stocksJson.forEach(function(element,index){
	   				var cargoName=element.cargo.cargoName||"暂无数据";
	   				var cargoNo=element.cargo.cargoNo||"暂无数据";
	 				stuffData.push($("<option value='"+element.cargoId+"'>"+cargoName+"   "+cargoNo+"   "+"</option>"));
				});
   			}
	        $("#adjustmentCargoId").append(stuffData);
	     	$("#adjustmentCargoId").trigger('bootstrapDualListbox.refresh');
       	}
    }); 
}
/* =======================绑定低耗品信息==================================== */

function submitForm(lbtn){
	console.log($("#adjustmentCargoId").val());
	if($("#adjustmentCargoId").val()==null){
		$.showTips("请选择盘点货品！",1000,"warning");
		return;
	}
	if (!$("form:first").valid()){
		return;
	}
	lbtn.start();
	$("#inventory").submit(); 
}

</script>

<%request.setAttribute("noScripts","formpickers.location;"); %>
<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/notifications.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/forminputs.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>
